home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-23 | 2.2 KB | 104 lines | [TEXT/PJMM] |
- {}
- { routines related to saying strings }
- unit MySpeech;
- interface
- uses
- FixMath, Speech, Globals, Daemon;
-
-
- { personal prototypes }
- function IsSpeechAvailable: Boolean;
- procedure PlayMySpeech (index: integer);
- procedure SayNumbers (days: LONGINT;
- index: integer);
- procedure PlayBites;
- { actual code }
- implementation
- uses
- Utility;
- const
- gestaltSpeechAttr = 'ttsc'; { Gestalt Manager selector for Speech Attributes }
- gestaltSpeechMgrPresent = 0; { Gestalt bit which indicates that Speech Manager exists }
- SPEECH_STRINGS = 400;
- BYTE_PROB_NUM = 25000;
-
-
- function IsSpeechAvailable: Boolean;
- var
- response: LONGINT;
- iErr: OSErr;
- begin
- IsSpeechAvailable := FALSE;
- iErr := Gestalt(gestaltSpeechAttr, response);
- if (BitTst(@response, 31 - gestaltSpeechMgrPresent)) and (iErr = 0) then
- begin
- IsSpeechAvailable := TRUE;
- end;
- end;
-
-
- procedure SayMyString (aString: Str255);
- var
- iErr: OSErr;
- byteLength: LONGINT;
- begin
- if gPreferences.useDaemon then
- begin
- Talk2Daemon(gPreferences, aString);
- end
- else
- begin
- iErr := SpeakString(aString);
- end;
- end;
-
- procedure SayNumbers (days: LONGINT;
- index: integer);
- var
- theString: Str255;
- dayString: Str255;
- begin
- GetIndString(dayString, SPEECH_STRINGS, index);
- NumToString(days, theString);
- theString := Concat(theString, dayString);
- SayMyString(theString);
- end;
-
- procedure PlayMySpeech (index: integer);
- var
- iErr: OSErr;
- byebyeString: Str255;
- begin
- GetIndString(byebyeString, SPEECH_STRINGS, index);
- SayMyString(byebyeString);
- end; (* PlayMySpeech *)
-
- procedure PlayBites;
- var
- randNum: integer;
- numStrings: integer;
- index: integer;
- aStringH: StringHandle;
- begin
- if gPreferences.sayBites then
- begin
- randNum := ChooseRandom(0, 32767);
-
- if randNum < gPreferences.biteFreq then
- begin
- numStrings := Count1Resources('BITE');
- if numStrings > 0 then
- begin
- index := ChooseRandom(1, numStrings);
- aStringH := StringHandle(Get1IndResource('BITE', index));
- if aStringH <> nil then
- begin
- SayMyString(aStringH^^);
- ReleaseResource(Handle(aStringH));
- end;
- end;
- end;
- end;
- end;
-
- end.